/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bookshop.managedBean;

import com.bookshop.entity.Book;
import com.bookshop.facade.BookFacade;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Thibault
 */
@ManagedBean(name="mbBook")
@SessionScoped
public class MBBook {
    @EJB
    private BookFacade bookFacade;
    
    private List<Book> books = new ArrayList<Book>();
    private Book book = new Book();

    public List<Book> getBooks() {
        return books;
    }

    public void setBooks(List<Book> books) {
        this.books = books;
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    /**
     * Creates a new instance of MBBook
     */
    public MBBook() {
    }
    
    public List<Book> getAllBooks() {
        return null; //bookFacade.retrieve();
    }
    
    public String search() {
        this.books.clear();
        this.books = bookFacade.findByTitle(this.book.getTitle());
        return "";
    }
}
